<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */

Text::h1( Lang::getBack('com_comment', 'admin') );

if (empty($_GET['a'])) {

    $query = $db->query("SELECT * FROM {prefix}comments ORDER BY date DESC");
    
    echo '<table cellspacing="20" cellpadding="30">';
    
    echo '<tr><th>'.Lang::getBack('com_comment', 'user').'</th><th>'.Lang::getBack('com_comment', 'component').'/th><th>'.Lang::getBack('com_comment', 'date').'</th><th>'.Lang::getBack('com_comment', 'text').'</th><th>'.Lang::getBackGlobal('com_comment', 'action').'</th></tr>';
    while ($data = $query->fetch_array()) {
        $user = ($data['author_id'] == 0) ? $data['username'] : User::getDisplayName($data['author_id']);
        echo '<tr><td>' . $user . '</td><td>' . $data['component'] .
            '</td><td>' . $data['date'] . '</td><td>' . $data['text'] . '</td><td><a href="' .
            $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '&a=delete&id=' . $data['id'] .
            '"><img src="../libs/icons/delete.png" /></a></td></tr>';
    }
    echo '</table>';

} else {
    switch ($_GET['a']) {
        case 'delete':
            require 'delete.php';
            break;
    }
}
?>